package com.behome.stream.common.domain;

import lombok.Data;

@Data
public class Result {

    private static final String SUCCESS = "操作成功";

    private static final String FAILURE = "操作失败";

    private int code;

    private String msg;

    private int count;

    private Object data;

    public Result(int code, String msg) {
        this(code, msg, null);
    }

    public Result(int code, String msg, Object data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public Result(int code, String msg, int count, Object data) {
        this.code = code;
        this.msg = msg;
        this.count = count;
        this.data = data;
    }

    public static Result succeed() {
        return new Result(200, SUCCESS);
    }


    public static Result succeed(String msg, Object data) {
        return new Result(200, msg, data);
    }

    public static Result succeed(String msg) {
        return new Result(200, msg);
    }

    public static Result succeed(String msg, int count, Object data) {
        return new Result(200, msg, count, data);
    }

    public static Result fail(int code, String msg) {
        return new Result(code, msg);
    }

    public static Result fail(int code, String msg, Object data) {
        return new Result(code, msg, data);
    }

    @Override
    public String toString() {
        return "Result [code=" + code + ", msg=" + msg + ", count=" + count + ", data=" + data + "]";
    }

}
